
package at.fhj.ase.clientarch.server.component;

import java.io.Serializable;
import java.rmi.RemoteException;

import at.fhj.ase.clientarch.common.User;
import at.fhj.ase.clientarch.common.component.IUserComponent;
import at.fhj.ase.clientarch.server.db.dao.impl.DatabaseController;
import at.fhj.ase.clientarch.server.db.hibernate.entities.EntityUser;

/**
 * @author cja, sfe | www.fh-joanneum.at | Client Architectures and Design
 * @see IUserComponent
 */
public class UserComponentImpl extends AbstractComponent implements IUserComponent, Serializable {
  private static final long serialVersionUID = 3761091559534240044L;

  UserComponentImpl() throws RemoteException {
    super();
  }

  @Override
  public boolean authenticateUser(final User user) {
    final EntityUser entityUser = DatabaseController.INSTANCE.getUserDao().findByUsernamePassword(user.getUsername(), user.getPassword());
    if (entityUser != null) {
      return true;
    }
    return false;
  }
}
